<template>
  <div style="overflow: auto">
    <el-container>
      <el-header style="height: auto">
        <div class="title">
          <div>入户基础信息  
            <template v-if="info.DSSV_IsInfoDone!=1">
              <el-tag v-if="info.DSSV_InfoUser==0 || info.DSSV_InfoUser==-1" type='danger'>未提交</el-tag>
              <el-tag v-else>已提交</el-tag>
            </template>
            
            <el-tag  @click = 'auditInfoVis=true' v-if="info.DSSV_IsInfoDone==-1" type='danger'>未审核</el-tag>
            <el-tag  @click = 'auditInfoVis=true' v-else :type=" info.DSSV_IsInfoDone?'':'danger'">{{ info.DSSV_IsInfoDone?'审核通过':'审核不通过' }}</el-tag>
          </div>
          <el-button @click="toMap()" size="small" type="primary">
            查看地图
          </el-button>
          <el-button @click="editSurveyVis = true" type="primary">
            修改信息
          </el-button>

        </div>
        <div class="info-box">
          <div>户主：{{ info.DSSV_Name }}</div>
          <div>身份证：{{ info.DSSV_IDCard }}</div>
          <div>手机号：{{ info.DSSV_Phone }}</div>
        </div>
        <div class="info-box">
          <div>是否代签：{{ info.DSSV_IsReplaceSign == null ? '否' : info.DSSV_IsReplaceSign ? '是' : '否'  }}</div>
          <div  v-if="info.DSSV_IsReplaceSign == true">代签人：{{ info.DSSV_ReplaceSignName }}</div>
        </div>
        <div class="info-box">
          <div>施工中减去炮前：{{ info.DSSV_IsAfootMinus == -1 ? '未选' : info.DSSV_IsAfootMinus ? '是' : '否' }}</div>
          <div>施工后减去炮前：{{ info.DSSV_IsAfterMinus == -1 ? '未选' : info.DSSV_IsAfterMinus ? '是' : '否' }}</div>
        </div>
        <div class="info-box">
          <div>村组：{{ info.DSSV_Village }}</div>
          <div>楼层：{{ info.DSSV_Floor }}</div>
          <div>
            结构：
            <span v-for="structure in info.DSSV_Structure" :key="structure">
              {{ structures[structure] }}
            </span>
          </div>
        </div>
        <div class="info-box">
          <div>距离：{{ info.DSSV_Distance }}</div>
        
          <div>是否住人：{{ liveStatus[info.DSSV_LiveStatus] }}</div>
          <div>备注：{{ info.DSSV_Remark }}</div>
        </div>
        <div class="info-box">
          <div>经度：{{ info.DSSV_Lat }}</div>
          <div>纬度：{{ info.DSSV_Lng }}</div>
        </div>
        <div class="title">
          <div>户型图 
            <template v-if="info.DSSV_IsPlaneDone!=1">
              <el-tag v-if="info.DSSV_PlaneUser==0 || info.DSSV_PlaneUser==-1" type='danger'>未提交</el-tag>
              <el-tag v-else>已提交</el-tag>
            </template>
            <el-tag  @click = 'auditInfoVis=true' v-if="info.DSSV_IsPlaneDone==-1" type='danger'>未审核</el-tag>
            <el-tag  @click = 'auditInfoVis=true' v-else :type=" info.DSSV_IsPlaneDone?'':'danger'">{{ info.DSSV_IsPlaneDone?'审核通过':'审核不通过' }}</el-tag>
          </div>
          <el-button @click="toDrawPlane()" size="small" type="primary">
            绘制
          </el-button>
          <!--<el-button
            @click="
              uploadPlaneVis = true
              uploadPlanePath = ''
            "
            size="small"
            type="primary"
          >
            上传
          </el-button>-->

        </div>

        <div style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap">
          <div
            style="
              position: relative;
              width: 200px;
              height: 200px;
              margin: 10px 20px;
            "
            v-for="(image, index) in plantImgPath"
            :key="index"
          >
            <el-image
              style="width: 200px; height: 200px"
              :src="image"
              :preview-src-list="plantImgPath"
            ></el-image>
            <div @click="UpdatePlaneImg(plantImg[index])" class="edit-btn-box">
              <i class="el-icon-edit edit-btn"></i>
              修改
            </div>
            <i
              @click="DeleteImg(plantImg[index].DSSIM_ID)"
              class="el-icon-error delete-btn"
            ></i>
            <div class="image-info">
              {{ plantImg[index].DSSIM_Name }}
            </div>
          </div>
        </div>

        <div class="title">
          <div>身份证</div>
          <el-button @click="addImage('3', 0)" size="small" type="primary">
            上传
          </el-button>
        </div>
        <div style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap">
          <div
            style="
              position: relative;
              width: 200px;
              height: 200px;
              margin: 10px 20px;
            "
            v-for="(image, index) in IDCardListPath"
            :key="index"
          >
            <el-image
              style="width: 200px; height: 200px"
              :src="image"
              :preview-src-list="IDCardListPath"
            ></el-image>
            <i
              @click="DeleteImg(IDCardList[index].DSSIM_ID)"
              class="el-icon-error delete-btn"
            ></i>
            <div class="image-info">身份证</div>
          </div>
        </div>
      </el-header>
      <el-main>
        <div class="title">
          <div>勘查信息
            <template v-if="info.DSSV_IsSurveyDone!=1">
              <el-tag v-if="info.DSSV_SurveyUser==0 || info.DSSV_SurveyUser==-1" type='danger'>未提交</el-tag>
              <el-tag v-else>已提交</el-tag>
            </template>
            <el-tag  @click = 'auditInfoVis=true' v-if="info.DSSV_IsSurveyDone==-1" type='danger'>未审核</el-tag>
            <el-tag  @click = 'auditInfoVis=true' v-else :type=" info.DSSV_IsSurveyDone?'':'danger'">{{ info.DSSV_IsSurveyDone?'审核通过':'审核不通过' }}</el-tag>

          </div>
            <el-button @click="doCommitSurveyAudit()" size="small" type="primary">
            提交
          </el-button>
        </div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane v-if="info.DSSV_HasBefore" :key="1" label="施工前" :name="1"></el-tab-pane>
          <el-tab-pane v-if="info.DSSV_HasAfoot" :key="2" label="施工中" :name="2"></el-tab-pane>
          <el-tab-pane v-if="info.DSSV_HasAfter" :key="3" label="施工后" :name="3"></el-tab-pane>
          <!--<div class="title">
            <div>勘查信息</div>
            <el-button @click="editRecordInfoVis = true" type="primary">
              资料管理
            </el-button>
          </div>
          <div class="info-box">
            <div>接收材料：{{ editRecordInfo.DSSS_ReceiveMaterialDate }}</div>
            <div>丢失材料：{{ editRecordInfo.DSSS_LostMaterialDate }}</div>
            <div>丢失清单：{{ editRecordInfo.DSSS_LostMaterialList }}</div>
          </div>-->
          <el-container style="height: 100%; border: 1px solid #eee">
            <el-aside
              width="40%"
              style="background-color: rgb(238, 241, 246); padding: 10px 20px"
            >
              <div :key="index" v-for="(record, index) in records">
                <div class="title">
                  <div>{{surveyStep[record.ListCount]}}</div>
                  <el-button
                  @click="doSetSurveyState(record)"
                  size="small"
                  type="primary"
                >
                  {{ record.IsDone ? '取消完成' : '完成勘查' }}
                </el-button>
                  <el-button
                    @click="
                      addSurveyRecordVis = true
                      addSurveyRecordStep = record.StepId
                    "
                    type="primary"
                  >
                    添加记录
                  </el-button>
                </div>
                <el-table
                  :data="record.Records"
                  :cell-style="{ color: '#fff' }"
                  :header-cell-style="{ color: '#fff' }"
                >
                  style="width: 100%">
                  <el-table-column
                    prop="DSSR_RoomNo"
                    label="房间"
                  ></el-table-column>
                  <el-table-column
                    label="已减炮前"
                  ><template slot-scope="scope">
                    {{
                      (scope.row.DSSR_IsMinusBefore == null || !scope.row.DSSR_IsMinusBefore )
                        ? '未减'
                        : '已减'
                    }}
                </template>
                </el-table-column>
                  <el-table-column
                    prop="DSSR_DamageType"
                    label="类型"
                  ></el-table-column>
                  <el-table-column
                    prop="DSSR_Direction"
                    label="方向"
                  ></el-table-column>
                  <el-table-column
                    prop="DSSR_Positon"
                    label="位置"
                  ></el-table-column>
                  <el-table-column
                    prop="DSSR_Count"
                    label="数量"
                  ></el-table-column>
                  <el-table-column
                    prop="DSSR_Unit"
                    label="单位"
                  ></el-table-column>
                  <el-table-column
                    prop="DSSR_BeforeSurveyDate"
                    label="日期"
                  ></el-table-column>
                  <el-table-column fixed="right" width="100">
                    <template slot="header" slot-scope="scope">操作</template>
                    <template slot-scope="scope">
                      <el-button
                        type="primary"
                        icon="el-icon-picture"
                        circle
                        @click="addImage('10', scope.row.DSSR_ID)"
                      ></el-button>
                      <el-button
                        type="danger"
                        icon="el-icon-delete"
                        circle
                        @click="doDeleteSurveyRecord(scope.row.DSSR_ID)"
                      ></el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-aside>
            <el-container style="padding: 20px" direction="vertical">
              <!--<div class="title">
                <div>勘查状态：{{ isDone ? '已完成' : '未完成' }}</div>
                
              </div>-->

              <div class="title">
                <div>勘查表</div>
                <el-button
                  @click="addImage('2', 0)"
                  size="small"
                  type="primary"
                >
                  上传（带身份证）
                </el-button>
                <el-button
                  @click="addImage('21', 0)"
                  size="small"
                  type="primary"
                >
                  上传（无身份证）
                </el-button>
              </div>
              <div
                style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap"
              >
                <div
                  style="
                    position: relative;
                    width: 200px;
                    height: 200px;
                    margin: 10px 20px;
                  "
                  v-for="(image, index) in tableImgPath"
                  :key="index"
                >
                  <el-image
                    style="width: 200px; height: 200px"
                    :src="image"
                    :preview-src-list="tableImgPath"
                  ></el-image>
                  <i
                    @click="DeleteImg(tableImg[index].DSSIM_ID)"
                    class="el-icon-error delete-btn"
                  ></i>
                  <div class="image-info">{{tableImg[index].DSSIM_Type==2?'带身份证':'不带身份证'}}</div>
                  <div @click="showOriginal(tableImg[index].FL_SrcPath)" class="image-original">原图</div>
                </div>
              </div>
              <div class="title">
                <div>全景图</div>
                <el-button
                  @click="addImage('4', 0)"
                  size="small"
                  type="primary"
                >
                  上传
                </el-button>
              </div>
              <div
                style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap"
              >
                <div
                  style="
                    position: relative;
                    width: 200px;
                    height: 200px;
                    margin: 10px 20px;
                  "
                  v-for="(image, index) in senceListPath"
                  :key="index"
                >
                  <el-image
                    style="width: 200px; height: 200px"
                    :src="image"
                    :preview-src-list="senceListPath"
                  ></el-image>
                  <i
                    @click="DeleteImg(senceList[index].DSSIM_ID)"
                    class="el-icon-error delete-btn"
                  ></i>
                  <div @click="showOriginal(senceList[index].FL_SrcPath)" class="image-original">原图</div>
                  <div class="image-info">全景图</div>
                </div>
              </div>
              <div class="title">
                <div>人景图</div>
                <el-button
                  @click="addImage('7', 0)"
                  size="small"
                  type="primary"
                >
                  上传
                </el-button>
              </div>
              <div
                style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap"
              >
                <div
                  style="
                    position: relative;
                    width: 200px;
                    height: 200px;
                    margin: 10px 20px;
                  "
                  v-for="(image, index) in peopleListPath"
                  :key="index"
                >
                  <el-image
                    style="width: 200px; height: 200px"
                    :src="image"
                    :preview-src-list="peopleListPath"
                  ></el-image>
                  <i
                    @click="DeleteImg(peopleList[index].DSSIM_ID)"
                    class="el-icon-error delete-btn"
                  ></i>
                  <div @click="showOriginal(peopleList[index].FL_SrcPath)" class="image-original">原图</div>
                  <div class="image-info">人景图</div>
                </div>
              </div>
              <div class="title">
                <div>勘查图</div>
                <el-button
                  @click="addImage('10', 0)"
                  size="small"
                  type="primary"
                >
                  上传
                </el-button>
              </div>
              <div
                style="margin: 10px 0 30px 0; display: flex; flex-wrap: wrap"
              >
                <div
                  style="
                    position: relative;
                    width: 200px;
                    height: 200px;
                    margin: 10px 20px;
                  "
                  v-for="(image, index) in imageListPath"
                  :key="index"
                >
                  <el-image
                    style="width: 200px; height: 200px"
                    :src="image"
                    :preview-src-list="imageListPath"
                  ></el-image>
                  <i
                    @click="DeleteImg(imageList[index].DSSIM_ID)"
                    class="el-icon-error delete-btn"
                  ></i>
                  <div
                    v-if="imageList[index].DSSR_RoomNo != null"
                    class="image-info"
                  >
                    房间{{ imageList[index].DSSR_RoomNo
                    }}{{ imageList[index].DSSR_Positon }}
                  </div>
                  <div v-else class="image-info">
                    {{ imageList[index].DSSIM_Name }}
                  </div>
                  <div @click="showOriginal(imageList[index].FL_SrcPath)" class="image-original">原图</div>
                </div>
              </div>
            </el-container>
          </el-container>
        </el-tabs>
      </el-main>
    </el-container>
    <el-dialog title="修改信息" :visible.sync="editSurveyVis">
      <el-form ref="form" :model="info" label-width="80px">
        <el-form-item label="户主姓名">
          <el-input v-model="info.DSSV_Name"></el-input>
        </el-form-item>
        <el-form-item label="村组">
          <el-input v-model="info.DSSV_Village"></el-input>
        </el-form-item>
        <el-form-item label="电话">
          <el-input v-model="info.DSSV_Phone"></el-input>
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="info.DSSV_IDCard"></el-input>
        </el-form-item>
        <el-form-item label="是否代签">
          <el-switch v-model="info.DSSV_IsReplaceSign"></el-switch>
        </el-form-item>
        <el-form-item v-if="info.DSSV_HasAfoot" label="施工中减去炮前">
          <el-switch v-model="isAfootMinus"></el-switch>
        </el-form-item>
        <el-form-item v-if="info.DSSV_HasAfter" label="施工后减去炮前">
          <el-switch v-model="isAfterMinus"></el-switch>
        </el-form-item>
        <el-form-item v-if="info.DSSV_IsReplaceSign == true" label="代签人">
          <el-input v-model="info.DSSV_ReplaceSignName"></el-input>
        </el-form-item>
        <el-form-item label="建筑结构">
          <el-select
            v-model="info.DSSV_Structure"
            multiple
            placeholder="请选择"
          >
            <el-option
              v-for="(value, key, index) in structures"
              :key="index"
              :label="value"
              :value="key"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="层数">
          <el-input v-model="info.DSSV_Floor"></el-input>
        </el-form-item>
        <el-form-item label="住人情况">
          <el-select v-model="info.DSSV_LiveStatus" placeholder="请选择">
            <el-option
              v-for="(value, key, index) in liveStatus"
              :key="index"
              :label="value"
              :value="key"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="距离">
          <el-select v-model="info.DSSV_Distance" placeholder="请选择">
            <el-option v-for="item in distance" :key="item" :label="item" :value="item"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="定损金额">
          <el-input type="number" v-model="info.DSSV_ConfirmMoney"></el-input>
        </el-form-item>
        <el-form-item label="经度">
          <el-input type="number" v-model="info.DSSV_Lat"></el-input>
        </el-form-item>
        <el-form-item label="纬度">
          <el-input type="number" v-model="info.DSSV_Lng"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="info.DSSV_Remark"></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="editSurveyVis = false">取 消</el-button>
        <el-button type="primary" @click="doModifySurvey">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="新增勘查明细" :visible.sync="addSurveyRecordVis">
      <el-form ref="form" :model="editSurveyRecord" label-width="80px">
        <el-form-item label="编号">
          <el-input v-model="addSurveyRecord.DSSR_No"></el-input>
        </el-form-item>
        <el-form-item label="减炮前">
          <el-radio-group v-model="addSurveyRecord.DSSR_IsMinusBefore">
            <el-radio :label="false">未减</el-radio>
            <el-radio :label="true">已减</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="房间号">
          <el-input v-model="addSurveyRecord.DSSR_RoomNo"></el-input>
        </el-form-item>
        <el-form-item label="受损项目">
          <el-input v-model="addSurveyRecord.DSSR_DamageItem"></el-input>
        </el-form-item>
        <el-form-item label="受损类型">
          <el-input v-model="addSurveyRecord.DSSR_DamageType"></el-input>
        </el-form-item>
        <el-form-item label="方向">
          <el-input v-model="addSurveyRecord.DSSR_Direction"></el-input>
        </el-form-item>
        <el-form-item label="数量">
          <el-input v-model="addSurveyRecord.DSSR_Count"></el-input>
        </el-form-item>
        <el-form-item label="单位">
          <el-input v-model="addSurveyRecord.DSSR_Unit"></el-input>
        </el-form-item>
        <el-form-item label="结构">
          <el-input v-model="addSurveyRecord.DSSR_RoomStructure"></el-input>
        </el-form-item>
        <el-form-item label="位置">
          <el-input v-model="addSurveyRecord.DSSR_Positon"></el-input>
        </el-form-item>
        <el-form-item label="距离">
          <el-input v-model="addSurveyRecord.DSSR_Distance"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="addSurveyRecord.DSSR_Remark"></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="editSurveyRecordVis = false">取 消</el-button>
        <el-button type="primary" @click="doAddSurveyRecord">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="审核情况" :visible.sync="auditInfoVis">
      <el-steps align-center>
        <el-step :status="auditInfo.infoAudit ? 'success' : 'process'" title="定位信息">
          <template slot="description">
            <div style="margin-top: 10px" v-for="info in auditInfo.infoAuditList" :key="info">
              {{ info.DSSA_CreateDate.split(' ')[0] }}{{ info.USR_Name }}:{{
                info.DSSA_Remark
              }}
            </div>
          </template>
        </el-step>

        <el-step :status="auditInfo.plantAudit ? 'success' : 'process'" title="户型图">
          <template slot="description">
            <div style="margin-top: 10px" v-for="info in auditInfo.plantAuditList" :key="info">
              {{ info.DSSA_CreateDate.split(' ')[0] }}{{ info.USR_Name }}:{{
                info.DSSA_Remark
              }}
            </div>
          </template>
        </el-step>

        <el-step :status="auditInfo.surveyAudit ? 'success' : 'process'" title="勘查信息">
          <template slot="description">
            <div style="margin-top: 10px" v-for="info in auditInfo.surveyAuditList" :key="info">
              {{ info.DSSA_CreateDate.split(' ')[0] }}{{ info.USR_Name }}:{{
                info.DSSA_Remark
              }}
            </div>
          </template>
        </el-step>
      </el-steps>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="auditInfoVis = false">确定</el-button>
      </div>
    </el-dialog>
    <!--<el-dialog title="勘查信息" :visible.sync="editRecordInfoVis">
      <el-form ref="form" :model="editRecordInfo" label-width="80px">
        <el-form-item label="接收资料时间">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="editRecordInfo.DSSS_ReceiveMaterialDate"
            style="width: 100%"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="丢失资料时间">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="editRecordInfo.DSSS_LostMaterialDate"
            style="width: 100%"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="丢失资料清单">
          <el-input v-model="editRecordInfo.DSSS_LostMaterialList"></el-input>
        </el-form-item>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="editRecordInfoVis = false">取 消</el-button>
        <el-button type="primary" @click="doSetSurveyStepInfo">确定</el-button>
      </div>
    </el-dialog>-->
    <el-dialog :visible.sync="addImgVis" destroy-on-close title="添加图片">
      <uploadImage
        :data="uploadImageData"
        @uploadSuccess="uploadSuccess"
      ></uploadImage>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addImgVis = false">取 消</el-button>
        <el-button type="primary" @click="addImgVis = false">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :visible.sync="auditSurveyVis"
      destroy-on-close
      :title="
        '审核' + auditType == 1
          ? '定位信息'
          : auditType == 2
          ? '户型图'
          : '勘查资料'
      "
    >
      <el-input
        type="textarea"
        placeholder="请输入审核内容"
        v-model="auditRemark"
        maxlength="100"
        show-word-limit
      ></el-input>
      <div slot="footer" class="dialog-footer">
        <el-button @click="audit(false)">拒绝</el-button>
        <el-button type="primary" @click="audit(true)">通过</el-button>
      </div>
    </el-dialog>

    <el-dialog
      :visible.sync="drawImgVis"
      :fullscreen="true"
      destroy-on-close
      title="绘制平面图"
    >
      <TinyWhiteboard
        @uploadSuccess="drawImgVis = false"
        style="width: 100%; height: 80vh"
        :isUpdate="isPlaneUpdate"
        :id="id"
      ></TinyWhiteboard>
    </el-dialog>

    <el-dialog
      :visible.sync="originalImgVis"
      title="查看原图"
    >
    <el-image
      style="width: 100%;"
      :src="originalImgUrl"
      :preview-src-list="[originalImgUrl]"
      ></el-image>
     
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="originalImgVis = false">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
  
  
  <script>
import { baseURL,imageServer } from '@/config'
import { GetProjectSteps } from '@/api/project/project.js'
import {
  GetSurvey,
  ModifySurvey,
  DeleteSurveyImage,
  GetSurveyRecords,
  AddSurveyRecord,
  DeleteSurveyRecord,
  GetSurveyImages,
  AddSurveyImage,
  AddRemoteSurveyImage,
  AddSurveyImages,
  SetSurveyStepInfo,
  SetSurveyStepUnDone,
  SetSurveyStepDone,
  SetSurveyListDone,
  SetSurveyListUnDone,
  GetSurveyStepInfo,
  GetSurveyPlaneImages,
  GetIDCardImages,
  AuditSurvey,
  GetSurveyAudits,
  CommitSurveyAudit
} from '@/api/project/survey.js'
import uploadImage from '../components/uploadImage.vue'
import TinyWhiteboard from '../components/TinyWhiteboard'
export default {
  components: { TinyWhiteboard, uploadImage },
  data() {
    return {
      id: 0,
      prjId: 0,
      isPlaneUpdate: false,
      projectSteps: [],
      addSurveyRecord: {},
      editSurveyRecordVis: false,
      addSurveyRecordVis: false,
      addSurveyRecordStep: 0,
      activeName: 1,
      isDone: false,
      repeatedList: [],
      images: [],
      uploadImageData: {
        stepId: 0,
        type: 0,
        files: [],
      },
      currentStep: {},
      records: [],
      TotalContainPrice: 0,
      TotalEliminatePrice: 0,
      beforeImgList: [],
      beforeImgPathList: [],
      plantImg: [],
      plantImgPath: [],

      IDCardList: [],
      IDCardListPath: [],

      tableImg: [],
      tableImgPath: [],

      imageList: [],
      imageListPath: [],

      senceList: [],
      senceListPath: [],

      peopleList: [],
      peopleListPath: [],

      addImgVis: false,
      editSurveyVis: false,
      imageType: '',
      uploadPath: baseURL + '/api/Survey/UploadImage',
      uploadPlaneVis: false,
      uploadPlanePath: '',
      uploadPlaneInfo: {
        name: '',
        type: 2,
        surveyId: 0,
      },
      drawImgVis: false,
      editRecordInfoVis: false,
      info: {},
      structures: {
        1: '木瓦',
        2: '砖瓦',
        3: '砖混',
        4: '土瓦',
        5: '石瓦',
        6: '框架',
        7: '其他',
      },
      liveStatus: {
        1: '住人',
        2: '空置',
        3: '其他',
      },
      distance: ['50到100米','100到150米','150到200米','200米以上','特殊'],
      editRecordInfo: {},
      auditSurveyVis: false,
      auditType: 0,
      auditRemark: '',
      surveyStep: {
        0: '首勘',
        1: '复勘',
        2: '二次复勘',
      },
      auditInfoVis: false,
      auditInfo:[],
      originalImgVis:false,
      originalImgUrl:null,
      isAfootMinus:null,
      isAfterMinus:null
    }
  },
  watch: {},

  methods: {
    audit(isPass) {
      var that = this
      if (this.auditRemark == '') {
        this.auditRemark = isPass ? '审核通过' : '审核不通过'
      }
      AuditSurvey(this.id, this.auditType, isPass, this.auditRemark).then(
        (r) => {
          that.auditSurveyVis = false
          that.auditRemark = ''
          that.auditType = 0
        }
      )
    },
    doGetProject() {
      var that = this
      GetProject(this.prjId).then((r) => {})
    },
    doModifySurvey() {
      var that = this
      var info = this.info
      info.DSSV_Structure = info.DSSV_Structure.toString()
      info.DSSV_IsAfootMinus= this.isAfootMinus==null?-1:this.isAfootMinus?1:0
      info.DSSV_IsAfterMinus= this.isAfterMinus==null?-1:this.isAfootMinus?1:0
      info.DSSV_LocationTime =  new Date();
      ModifySurvey(info).then((r) => {
        that.editSurveyVis = false
        that.doGetSurvey()
      })
    },
    doCommitSurveyAudit(){
      var that = this
      
      this.$confirm('确定提交勘察审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          CommitSurveyAudit(this.id).then((r) => {
            that.doGetSurvey()
        })
        })
        .catch(() => {})
       
    },
    doGetProjectSteps() {
      var that = this
      GetProjectSteps(this.prjId).then((r) => {
        that.projectSteps = r.data

        that.currentStep = r.data.beforeSteps
        //that.doGetSurveyImages()
        //that.doGetSurveyRecords()
        that.doGetSurveyStepInfo()
      })
    },
    doGetSurveyStepInfo() {
      var that = this
      this.currentStep.forEach((step) => {
        GetSurveyStepInfo(step.DSPJS_ID, this.id).then((r) => {
          that.editRecordInfo = r.data
        })
      })
    },
    doSetSurveyState(row) {
      var that = this
      
      this.$confirm('确定更改状态?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {

          if (row.IsDone) {
            SetSurveyListUnDone(row.MapId,that.activeName).then((r) => {
              that.doGetSurveyRecords()
              that.doGetSurvey()
            })
          } else {
            SetSurveyListDone(row.MapId,that.activeName).then((r) => {
              that.doGetSurveyRecords()
              that.doGetSurvey()
            })
          }
        })
        .catch(() => {})
    },
    doSetSurveyStepInfo() {
      var that = this
      SetSurveyStepUnDone(this.editRecordInfo).then((r) => {
        that.doGetSurveyStepInfo()
      })
    },
    doGetSurveyPlaneImages() {
      var that = this
      that.plantImg = []
      that.plantImgPath = []
      GetSurveyPlaneImages(this.id).then((r) => {
        r.data.forEach((img) => {
          that.plantImg.push(img)
          that.plantImgPath.push(
          baseURL +
              '/FileRoot/' +
              img.DSSIM_Path +
              '?t=' +
              new Date().getTime()
          )
        })
      })
    },
    doGetSurveyIDCardImages() {
      var that = this
      that.IDCardList = []
      that.IDCardListPath = []
      GetIDCardImages(this.id).then((r) => {
        var path =  img.FL_LmtPath?img.FL_LmtPath:img.FL_SrcPath
        r.data.forEach((img) => {
          that.IDCardList.push(img)
          that.IDCardListPath.push(imageServer + '/FileRoot/' + path)
        })
      })
    },
    doGetSurveyImages() {
      var that = this
      GetSurveyImages(this.activeName, this.id).then((r) => {
        that.tableImg = []
        that.tableImgPath = []
        that.imageList = []
        that.imageListPath = []
        that.senceList = []
        that.senceListPath=[]
        that.peopleList=[]
        that.peopleListPath=[]
        r.data.forEach((img) => {
          var path =  img.FL_LmtPath?img.FL_LmtPath:img.FL_SrcPath
          switch (img.DSSIM_Type) {
            case 2:
            case 21:
              that.tableImg.push(img)
              that.tableImgPath.push(imageServer + '/FileRoot/' + path)
              break
            case 4:
              that.senceList.push(img)
              that.senceListPath.push(imageServer + '/FileRoot/' +path)
             break;
            case 7:
              that.peopleList.push(img)
              that.peopleListPath.push(imageServer + '/FileRoot/' + path)
             break;
            default:
              that.imageList.push(img)
              that.imageListPath.push(imageServer + '/FileRoot/' + path)
              break
          }
        })
      })
    },
    doAddSurveyRecord() {
      var that = this
      this.addSurveyRecord.DSSR_SurveyID = this.id
      this.addSurveyRecord.DSSR_SurveyListID = this.addSurveyRecordStep
      AddSurveyRecord(this.addSurveyRecord).then((r) => {
        that.addSurveyRecordVis = false
        that.addSurveyRecord = {}
        that.doGetSurveyRecords()
      })
    },
    doDeleteSurveyRecord(id) {
      var that = this
      this.$confirm('确定删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          DeleteSurveyRecord(id).then((r) => {
            that.doGetSurveyRecords()
          })
        })
        .catch(() => {})
    },
    doGetSurveyRecords() {
      var that = this
      GetSurveyRecords(this.activeName, this.id).then((r) => {
        that.records = r.data
        
        console.log(that.records)
      })
    },
    toDrawPlane() {
      this.$router.push({
        name: 'surveyPlane',
        query: { id: this.id, isUpdate: false },
      })
    },
    toMap() {
      this.$router.push({
        name: 'surveyMap',
        query: { name: this.info.DSSV_Name, id: this.prjId },
      })
    },
    UpdatePlaneImg(img) {
      this.$router.push({
        name: 'surveyPlane',
        query: {
          id: this.id,
          isUpdate: true,
          name: img.DSSIM_Name,
          path: baseURL + '/FileRoot/' + img.DSSIM_Path.split('.')[0] + '.json',
        },
      })
    },
    uploadSuccess(r) {
      var that = this

      var image = {
        DSSIM_Path:r.data.FL_SrcPath,
        DSSIM_SurveyID: this.id,
        //DSSIM_FileID: r.data.FL_ID,
        DSSIM_SurveyRecordID: this.uploadImageData.surveyRecordId,
        DSSIM_Name: r.data.name,
        DSSIM_Type: this.uploadImageData.type,
        DSSIM_ProjectStepID: this.activeName,
      }
      AddRemoteSurveyImage({image:image,file:r.data}).then((r) => {
        that.doGetSurveyImages()
        that.doGetSurveyIDCardImages()
        that.doGetSurveyPlaneImages()
      })
      /*var images = [image, image]
      AddSurveyImages(images).then((r) => {
        that.doGetSurveyImages()
      })*/
    },
    handleClick(tab, event) {
      console.log(tab.name)
      this.currentStep = this.projectSteps[tab.name]
      this.doGetSurveyRecords()
      this.doGetSurveyImages()
    },
    addImage(type, id) {
      this.uploadImageData = {
        type: type,

        surveyRecordId: id,
      }
      this.addImgVis = true
    },
    DeleteImg(id) {
      var that = this
      this.$confirm('此操作将永久删除图片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          DeleteSurveyImage(id).then((r) => {
            that.doGetSurvey()
            that.doGetSurveyIDCardImages()
            that.doGetSurveyImages()
            that.doGetSurveyPlaneImages()
            this.$message({
              type: 'info',
              message: '已成功删除',
            })
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除',
          })
        })
    },
    GetSurveyAudits() {
      var that = this

      GetSurveyAudits(this.id).then((r) => {
        console.log(r)
        that.auditInfo = r.data
      })
    },
    doGetSurvey() {
      var that = this

      GetSurvey(this.id).then((r) => {
        that.info = r.data
        if(r.data.DSSV_HasBefore){
          that.activeName=1
        }else if(r.data.DSSV_HasAfoot){
          that.activeName=2
        }else if(r.data.DSSV_HasAfter){
          that.activeName=3
        }
        that.doGetSurveyImages()
        that.doGetSurveyRecords()
        that.info.DSSV_Structure = that.info.DSSV_Structure.split(',')
        switch (that.activeName) {
          case 1:
            that.isDone = that.info.DSSV_BeforeIsDone
            break
          case 2:
            that.isDone = that.info.DSSV_AfootIsDone
            break
          case 3:
            that.isDone = that.info.DSSV_AfterIsDone
            break
        }
      })
    },
    showOriginal(src){
      this.originalImgUrl=imageServer + '/FileRoot/' +src
      this.originalImgVis=true
    }
  },
  created: function () {
    this.id = this.$route.query.id
    this.prjId = this.$route.query.prjId
  },
  mounted: function () {
    this.doGetProjectSteps()
    this.doGetSurvey()
    this.doGetSurveyPlaneImages()
    this.doGetSurveyIDCardImages()
    this.GetSurveyAudits()
  },
}
</script>
<style scoped>
/*最外层透明*/
::v-deep .el-table,
::v-deep .el-table__expanded-cell {
  background-color: transparent !important;
}
/* 表格内背景颜色 */
::v-deep .el-table th,
::v-deep .el-table tr,
::v-deep .el-table td {
  background-color: transparent !important;
}

.title {
  height: 40px;
  line-height: 40px;
  display: flex;
  padding: 10px 0;
  margin: 10px 0;
  background-color: #fff;
}
.title div {
  flex: 1;
}
.title:before {
  width: 10px;
  height: 25px;
  margin: 7.5px;
  background-color: blue;
  content: '';
}
.info-box {
  height: 35px;
  line-height: 35px;
  display: flex;
  font-size: 15px;
}
.info-title {
  height: 45px;
  line-height: 45px;
  font-size: 16px;
  font-weight: bolder;
}
.info-box div {
  flex: 1;
}
.image-original{
  position: absolute;
  left: 0;
  bottom: 0;
  background-color: #409eff;
  color: #fff;
  padding: 2px 5px;
}
.info-image {
  width: 50px;
  height: 50px;
}

.delete-btn {
  display: block;
  position: absolute;
  right: -10px;
  top: -10px;
  color: red;
  font-size: 22px;
}
.edit-btn-box {
  display: block;
  position: absolute;
  left: 0px;
  bottom: 0px;

  background-color: #409eff;
  color: white;
  padding: 2px 5px;
}
.edit-btn {
}
.image-info {
  position: absolute;
  right: 0;
  bottom: 0;
  background-color: #000;
  opacity: 0.7;
  color: #fff;
  padding: 2px 5px;
}

.el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.el-upload:hover {
  border-color: #409eff;
}
.uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
  